package com.supermarket.api.service.impl;

import com.supermarket.api.common.Constants;
import com.supermarket.api.entity.AdvertiseEntity;
import com.supermarket.api.repository.AdvertiseRepository;
import com.supermarket.api.service.AdvertiseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 首页广告服务层
 * @author 李其伟
 * @date 2023/10/23
 */
@Slf4j
@Service
public class AdvertiseServiceImpl implements AdvertiseService {

    @Autowired
    private AdvertiseRepository advertiseRepository;

    @Override
    public List<AdvertiseEntity> list() {
        Date now= new Date();
        return advertiseRepository.queryAllByPublishStatusAndStartTimeLessThanAndEndTimeGreaterThanOrderBySortDesc(Constants.PUBLISH_STATUS_UP,now,now);
    }
}
